{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "name:曾露莎"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns\n",
    "import scipy.spatial.distance as ssd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user</th>\n",
       "      <th>song</th>\n",
       "      <th>play_count</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>4e11f45d732f4861772b2906f81a7d384552ad12</td>\n",
       "      <td>SOCKSGZ12A58A7CA4B</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>4e11f45d732f4861772b2906f81a7d384552ad12</td>\n",
       "      <td>SOCVTLJ12A6310F0FD</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>4e11f45d732f4861772b2906f81a7d384552ad12</td>\n",
       "      <td>SODLLYS12A8C13A96B</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4e11f45d732f4861772b2906f81a7d384552ad12</td>\n",
       "      <td>SOEGIYH12A6D4FC0E3</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4e11f45d732f4861772b2906f81a7d384552ad12</td>\n",
       "      <td>SOFRQTD12A81C233C0</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                       user                song  play_count\n",
       "0  4e11f45d732f4861772b2906f81a7d384552ad12  SOCKSGZ12A58A7CA4B           1\n",
       "1  4e11f45d732f4861772b2906f81a7d384552ad12  SOCVTLJ12A6310F0FD           1\n",
       "2  4e11f45d732f4861772b2906f81a7d384552ad12  SODLLYS12A8C13A96B           3\n",
       "3  4e11f45d732f4861772b2906f81a7d384552ad12  SOEGIYH12A6D4FC0E3           1\n",
       "4  4e11f45d732f4861772b2906f81a7d384552ad12  SOFRQTD12A81C233C0           2"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "User_Song_Data = pd.read_csv('triplet_dataset_sub.csv')# sep='\\t', names=u_cols,encoding='latin-1')\n",
    "\n",
    "User_Song_Data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "#User_Song_Data.user.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 37519 entries, 0 to 37518\n",
      "Data columns (total 3 columns):\n",
      "user          37519 non-null object\n",
      "song          37519 non-null object\n",
      "play_count    37519 non-null int64\n",
      "dtypes: int64(1), object(2)\n",
      "memory usage: 879.4+ KB\n"
     ]
    }
   ],
   "source": [
    "User_Song_Data.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>play_count</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>37519.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>8.799222</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>33.401146</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>3.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>8.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>3532.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         play_count\n",
       "count  37519.000000\n",
       "mean       8.799222\n",
       "std       33.401146\n",
       "min        1.000000\n",
       "25%        1.000000\n",
       "50%        3.000000\n",
       "75%        8.000000\n",
       "max     3532.000000"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "User_Song_Data.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x7f2a2caeb8d0>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZ0AAAELCAYAAAAC4Fv8AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvDW2N/gAAHq9JREFUeJzt3X+cXXV95/HXOwm/MSYEipqwJKypNlhFnALWbuvqFoK1hlp0sf4ImG12V3Tb3fqwYvexKOo+9LF9LAWBpKn8LooUfxAtitmIP2oLkkhEIGJSEJMYkpCEhAgJmcxn//h+v94zl5nJZDLzvTOZ9/PxmMc953t+fc+55573+Z575lxFBGZmZjVM6HQFzMxs/HDomJlZNQ4dMzOrxqFjZmbVOHTMzKwah46ZmVXj0DEzs2ocOmZmVo1Dx8zMqpnU6QrUdvzxx8fMmTM7XQ0zszFl5cqVT0bECQc7n3EXOjNnzmTFihWdroaZ2Zgi6fHhmI8vr5mZWTUOHTMzq8ahY2Zm1Th0zMysGoeOmZlV49AxM7NqHDpmZlaNQ8fMzKpx6JiZWTXjLnS6t2zrdBXMzMatcRc6ZmbWOQ4dMzOrZsRCR9J1kjZLerBR9n8k/UTSA5K+LGlKY9glktZKekTSOY3yublsraQPN8pnSbo3l39B0uEjtS5mZjY8RrKlcwMwt61sGfCKiHgl8FPgEgBJc4ALgFPzNNdImihpInA1cC4wB3hHHhfg08DlEfFSYDuwYATXxczMhsGIhU5EfBfY1lb2zYjozr33ADNy9zzg1ojYExGPAWuBM/Lf2oh4NCKeA24F5kkS8Abg9jz9jcB5I7UuZmY2PDr5nc57ga/n7unAusaw9bmsv/JpwFONACvlZmY2inUkdCT9FdAN3FJpeQslrZC0YuuunTUWaWZmfageOpIuBN4MvDMiIhdvAE5qjDYjl/VXvhWYImlSW3mfImJJRHRFRNe0YycPy3qYmdmBqxo6kuYCHwLeEhHPNAYtBS6QdISkWcBs4AfAfc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      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.countplot(User_Song_Data['play_count'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1       12410\n",
       "2        5273\n",
       "3        3198\n",
       "4        2275\n",
       "5        2228\n",
       "6        1513\n",
       "7        1103\n",
       "8         928\n",
       "9         763\n",
       "10        705\n",
       "11        613\n",
       "12        530\n",
       "13        417\n",
       "14        402\n",
       "15        390\n",
       "16        359\n",
       "17        307\n",
       "18        277\n",
       "19        234\n",
       "20        220\n",
       "21        211\n",
       "22        192\n",
       "23        176\n",
       "24        156\n",
       "26        141\n",
       "27        132\n",
       "25        126\n",
       "29        105\n",
       "31         90\n",
       "30         87\n",
       "        ...  \n",
       "239         1\n",
       "223         1\n",
       "295         1\n",
       "1134        1\n",
       "200         1\n",
       "264         1\n",
       "508         1\n",
       "220         1\n",
       "169         1\n",
       "201         1\n",
       "809         1\n",
       "156         1\n",
       "138         1\n",
       "202         1\n",
       "298         1\n",
       "522         1\n",
       "906         1\n",
       "203         1\n",
       "267         1\n",
       "683         1\n",
       "1435        1\n",
       "1115        1\n",
       "140         1\n",
       "716         1\n",
       "315         1\n",
       "3532        1\n",
       "123         1\n",
       "174         1\n",
       "462         1\n",
       "319         1\n",
       "Name: play_count, Length: 248, dtype: int64"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "User_Song_Data['play_count'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "play_count    3.0\n",
       "Name: 0.5, dtype: float64"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "User_Song_Data.quantile(.5)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "在概率密度曲线上，\n",
    "95%~100%,播放次数大于31\n",
    "90%~95%,播放次数在19~31\n",
    "80%~90%,播放次数在10到19之间\n",
    "70%~80%，播放次数在6到10之间\n",
    "60%~70%，播放次数在4到6之间\n",
    "50%~60%，播放次数在3到4之间\n",
    "33%~50%,播放次数在2到3之间\n",
    "<33%,1\n",
    "\n",
    "分数映射表：\n",
    "播放次数1->1\n",
    "播放次数2->2\n",
    "播放次数3->3\n",
    "播放次数4,5->4\n",
    "播放次数[6,9]->5\n",
    "播放次数[10,18]->6\n",
    "播放次数[19,30]->7\n",
    "播放次数>=31->8\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "def fun1(x):\n",
    "    if x in [1,2,3]:\n",
    "        return x\n",
    "    if x in [4,5]:\n",
    "        return 4\n",
    "    if x in np.linspace(6,9,4,dtype='int'):\n",
    "        return 5\n",
    "    if x in np.linspace(10,18,9,dtype='int'):\n",
    "        return 6\n",
    "    if x in np.linspace(19,30,12,dtype='int'):\n",
    "        return 7\n",
    "    if x >=31:\n",
    "        return 8    \n",
    " \n",
    "User_Song_Data['Score']= User_Song_Data['play_count'].apply(lambda x: fun1(x))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 37519 entries, 0 to 37518\n",
      "Data columns (total 4 columns):\n",
      "user          37519 non-null object\n",
      "song          37519 non-null object\n",
      "play_count    37519 non-null int64\n",
      "Score         37519 non-null int64\n",
      "dtypes: int64(2), object(2)\n",
      "memory usage: 1.1+ MB\n"
     ]
    }
   ],
   "source": [
    "User_Song_Data.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.preprocessing import LabelEncoder\n",
    "lb_Encoder_user=LabelEncoder()\n",
    "lb_Encoder_song=LabelEncoder()\n",
    "User_Song_Data['Userid']=lb_Encoder_user.fit_transform(User_Song_Data['user'])\n",
    "User_Song_Data['Songid']=lb_Encoder_song.fit_transform(User_Song_Data['song'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "User_Song_Data = User_Song_Data.sort_values(by = 'Userid', ascending = True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user</th>\n",
       "      <th>song</th>\n",
       "      <th>play_count</th>\n",
       "      <th>Score</th>\n",
       "      <th>Userid</th>\n",
       "      <th>Songid</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>18856</th>\n",
       "      <td>0025bfe6248070545d23721083acd3f60451da4f</td>\n",
       "      <td>SOSFPMR12A8C13D44A</td>\n",
       "      <td>16</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>300</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18860</th>\n",
       "      <td>0025bfe6248070545d23721083acd3f60451da4f</td>\n",
       "      <td>SOYZOUY12AAF3B5B94</td>\n",
       "      <td>11</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>745</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18859</th>\n",
       "      <td>0025bfe6248070545d23721083acd3f60451da4f</td>\n",
       "      <td>SOXHYVQ12AB0187949</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>635</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18858</th>\n",
       "      <td>0025bfe6248070545d23721083acd3f60451da4f</td>\n",
       "      <td>SOTNHIP12AB0183131</td>\n",
       "      <td>6</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>377</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18857</th>\n",
       "      <td>0025bfe6248070545d23721083acd3f60451da4f</td>\n",
       "      <td>SOSYHME12A8C135DD8</td>\n",
       "      <td>17</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>342</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27363</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SOSJFDH12A8C143096</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>307</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27362</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SOSJDQJ12A8C13D4A9</td>\n",
       "      <td>9</td>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>306</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27361</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SOSELMV12A6D4FCF5A</td>\n",
       "      <td>13</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>298</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27360</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SOSCIZP12AB0181D2F</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>297</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27359</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SORZCTH12A6D4FB0BD</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>292</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27358</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SORWLTW12A670208FA</td>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>288</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27357</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SORUFVF12AB018230B</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>281</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27356</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SORKVID12A6D4FC6D2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>273</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27355</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SORJVDO12AF72A1970</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>270</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27354</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SORJICW12A8C13640D</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>269</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27364</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SOSJSSU12A6D4F8F41</td>\n",
       "      <td>15</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>309</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27445</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SOZVVRE12A8C143150</td>\n",
       "      <td>12</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>791</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27352</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SOQWSHS12A6701C576</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>254</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27351</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SOQKNEO12A58A78EE7</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>241</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27350</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SOPZVSB12A8C13E2EF</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>225</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27349</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SOPXKYD12A6D4FA876</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>222</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27348</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SOPTLQL12AB018D56F</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>215</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27347</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SOPSYOY12A8C142E0B</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>214</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27346</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SOPREHY12AB01815F9</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>212</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27345</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SOPQLBY12A6310E992</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>210</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27344</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SOPPROJ12AB0184E18</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>209</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27343</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SOPLAHV12A8C13D110</td>\n",
       "      <td>13</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>206</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27342</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SOPIEIJ12A6D4F8F81</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>200</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27341</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SOPAYPV12AB017DB0C</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>192</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27340</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SOPABZM12A6D4FC668</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>191</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27431</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SOXWYZP12AF72A42A6</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>674</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27432</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SOYBHSI12A58A7D58B</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>685</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27433</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SOYDTRQ12AF72A3D61</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>692</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27434</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SOYEQLD12AB017C713</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>694</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27435</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SOYGHOJ12A6701FFBA</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>700</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27418</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SOXBCZH12A67ADAD77</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>606</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27427</th>\n",
       "      <td>002b63a7e2247de6d62bc62f253474edc7dd044c</td>\n",
       "      <td>SOXNZOW12AB017F756</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>658</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26697</th>\n",
       "      <td>003a5e3285141b1a54edbc51fbfa1cc922023aae</td>\n",
       "      <td>SOXAHKA12AF72A5A65</td>\n",
       "      <td>58</td>\n",
       "      <td>8</td>\n",
       "      <td>2</td>\n",
       "      <td>604</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26696</th>\n",
       "      <td>003a5e3285141b1a54edbc51fbfa1cc922023aae</td>\n",
       "      <td>SOWSPUS12AC468BEE3</td>\n",
       "      <td>51</td>\n",
       "      <td>8</td>\n",
       "      <td>2</td>\n",
       "      <td>589</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26698</th>\n",
       "      <td>003a5e3285141b1a54edbc51fbfa1cc922023aae</td>\n",
       "      <td>SOXCEYU12A6D4F3E70</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>611</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26699</th>\n",
       "      <td>003a5e3285141b1a54edbc51fbfa1cc922023aae</td>\n",
       "      <td>SOXFPND12AB017C9D1</td>\n",
       "      <td>36</td>\n",
       "      <td>8</td>\n",
       "      <td>2</td>\n",
       "      <td>626</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26700</th>\n",
       "      <td>003a5e3285141b1a54edbc51fbfa1cc922023aae</td>\n",
       "      <td>SOXGXKY12A8C13A405</td>\n",
       "      <td>14</td>\n",
       "      <td>6</td>\n",
       "      <td>2</td>\n",
       "      <td>632</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26701</th>\n",
       "      <td>003a5e3285141b1a54edbc51fbfa1cc922023aae</td>\n",
       "      <td>SOXLWPN12A8C143667</td>\n",
       "      <td>6</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>653</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26702</th>\n",
       "      <td>003a5e3285141b1a54edbc51fbfa1cc922023aae</td>\n",
       "      <td>SOYFQVR12AB018ACA5</td>\n",
       "      <td>10</td>\n",
       "      <td>6</td>\n",
       "      <td>2</td>\n",
       "      <td>699</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26703</th>\n",
       "      <td>003a5e3285141b1a54edbc51fbfa1cc922023aae</td>\n",
       "      <td>SOYGKNI12AB0187E6E</td>\n",
       "      <td>7</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>702</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26704</th>\n",
       "      <td>003a5e3285141b1a54edbc51fbfa1cc922023aae</td>\n",
       "      <td>SOYYFLV12A58A7A88F</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>740</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26705</th>\n",
       "      <td>003a5e3285141b1a54edbc51fbfa1cc922023aae</td>\n",
       "      <td>SOZGDUH12AF72A6DB2</td>\n",
       "      <td>7</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>765</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26695</th>\n",
       "      <td>003a5e3285141b1a54edbc51fbfa1cc922023aae</td>\n",
       "      <td>SOWPRYI12A58A7B51A</td>\n",
       "      <td>6</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>577</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26694</th>\n",
       "      <td>003a5e3285141b1a54edbc51fbfa1cc922023aae</td>\n",
       "      <td>SOWKYIJ12AB017B0AA</td>\n",
       "      <td>7</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>561</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26681</th>\n",
       "      <td>003a5e3285141b1a54edbc51fbfa1cc922023aae</td>\n",
       "      <td>SOTEPSZ12AB018C99D</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>358</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26691</th>\n",
       "      <td>003a5e3285141b1a54edbc51fbfa1cc922023aae</td>\n",
       "      <td>SOVTLQW12AB0186641</td>\n",
       "      <td>54</td>\n",
       "      <td>8</td>\n",
       "      <td>2</td>\n",
       "      <td>510</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26664</th>\n",
       "      <td>003a5e3285141b1a54edbc51fbfa1cc922023aae</td>\n",
       "      <td>SOBOUPA12A6D4F81F1</td>\n",
       "      <td>6</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26665</th>\n",
       "      <td>003a5e3285141b1a54edbc51fbfa1cc922023aae</td>\n",
       "      <td>SOFRQTD12A81C233C0</td>\n",
       "      <td>9</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26693</th>\n",
       "      <td>003a5e3285141b1a54edbc51fbfa1cc922023aae</td>\n",
       "      <td>SOWGCMN12A8C136E44</td>\n",
       "      <td>21</td>\n",
       "      <td>7</td>\n",
       "      <td>2</td>\n",
       "      <td>543</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26667</th>\n",
       "      <td>003a5e3285141b1a54edbc51fbfa1cc922023aae</td>\n",
       "      <td>SOGSAYQ12AB018BA14</td>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26668</th>\n",
       "      <td>003a5e3285141b1a54edbc51fbfa1cc922023aae</td>\n",
       "      <td>SOISNSU12AC468C0D8</td>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>52</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26669</th>\n",
       "      <td>003a5e3285141b1a54edbc51fbfa1cc922023aae</td>\n",
       "      <td>SOKOXWU12AF72AD1BC</td>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>71</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26670</th>\n",
       "      <td>003a5e3285141b1a54edbc51fbfa1cc922023aae</td>\n",
       "      <td>SOLAUOW12A8C13A400</td>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>83</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26671</th>\n",
       "      <td>003a5e3285141b1a54edbc51fbfa1cc922023aae</td>\n",
       "      <td>SOLRPJX12A58A79808</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26672</th>\n",
       "      <td>003a5e3285141b1a54edbc51fbfa1cc922023aae</td>\n",
       "      <td>SOMGIYR12AB0187973</td>\n",
       "      <td>52</td>\n",
       "      <td>8</td>\n",
       "      <td>2</td>\n",
       "      <td>113</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>200 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                           user                song  \\\n",
       "18856  0025bfe6248070545d23721083acd3f60451da4f  SOSFPMR12A8C13D44A   \n",
       "18860  0025bfe6248070545d23721083acd3f60451da4f  SOYZOUY12AAF3B5B94   \n",
       "18859  0025bfe6248070545d23721083acd3f60451da4f  SOXHYVQ12AB0187949   \n",
       "18858  0025bfe6248070545d23721083acd3f60451da4f  SOTNHIP12AB0183131   \n",
       "18857  0025bfe6248070545d23721083acd3f60451da4f  SOSYHME12A8C135DD8   \n",
       "27363  002b63a7e2247de6d62bc62f253474edc7dd044c  SOSJFDH12A8C143096   \n",
       "27362  002b63a7e2247de6d62bc62f253474edc7dd044c  SOSJDQJ12A8C13D4A9   \n",
       "27361  002b63a7e2247de6d62bc62f253474edc7dd044c  SOSELMV12A6D4FCF5A   \n",
       "27360  002b63a7e2247de6d62bc62f253474edc7dd044c  SOSCIZP12AB0181D2F   \n",
       "27359  002b63a7e2247de6d62bc62f253474edc7dd044c  SORZCTH12A6D4FB0BD   \n",
       "27358  002b63a7e2247de6d62bc62f253474edc7dd044c  SORWLTW12A670208FA   \n",
       "27357  002b63a7e2247de6d62bc62f253474edc7dd044c  SORUFVF12AB018230B   \n",
       "27356  002b63a7e2247de6d62bc62f253474edc7dd044c  SORKVID12A6D4FC6D2   \n",
       "27355  002b63a7e2247de6d62bc62f253474edc7dd044c  SORJVDO12AF72A1970   \n",
       "27354  002b63a7e2247de6d62bc62f253474edc7dd044c  SORJICW12A8C13640D   \n",
       "27364  002b63a7e2247de6d62bc62f253474edc7dd044c  SOSJSSU12A6D4F8F41   \n",
       "27445  002b63a7e2247de6d62bc62f253474edc7dd044c  SOZVVRE12A8C143150   \n",
       "27352  002b63a7e2247de6d62bc62f253474edc7dd044c  SOQWSHS12A6701C576   \n",
       "27351  002b63a7e2247de6d62bc62f253474edc7dd044c  SOQKNEO12A58A78EE7   \n",
       "27350  002b63a7e2247de6d62bc62f253474edc7dd044c  SOPZVSB12A8C13E2EF   \n",
       "27349  002b63a7e2247de6d62bc62f253474edc7dd044c  SOPXKYD12A6D4FA876   \n",
       "27348  002b63a7e2247de6d62bc62f253474edc7dd044c  SOPTLQL12AB018D56F   \n",
       "27347  002b63a7e2247de6d62bc62f253474edc7dd044c  SOPSYOY12A8C142E0B   \n",
       "27346  002b63a7e2247de6d62bc62f253474edc7dd044c  SOPREHY12AB01815F9   \n",
       "27345  002b63a7e2247de6d62bc62f253474edc7dd044c  SOPQLBY12A6310E992   \n",
       "27344  002b63a7e2247de6d62bc62f253474edc7dd044c  SOPPROJ12AB0184E18   \n",
       "27343  002b63a7e2247de6d62bc62f253474edc7dd044c  SOPLAHV12A8C13D110   \n",
       "27342  002b63a7e2247de6d62bc62f253474edc7dd044c  SOPIEIJ12A6D4F8F81   \n",
       "27341  002b63a7e2247de6d62bc62f253474edc7dd044c  SOPAYPV12AB017DB0C   \n",
       "27340  002b63a7e2247de6d62bc62f253474edc7dd044c  SOPABZM12A6D4FC668   \n",
       "...                                         ...                 ...   \n",
       "27431  002b63a7e2247de6d62bc62f253474edc7dd044c  SOXWYZP12AF72A42A6   \n",
       "27432  002b63a7e2247de6d62bc62f253474edc7dd044c  SOYBHSI12A58A7D58B   \n",
       "27433  002b63a7e2247de6d62bc62f253474edc7dd044c  SOYDTRQ12AF72A3D61   \n",
       "27434  002b63a7e2247de6d62bc62f253474edc7dd044c  SOYEQLD12AB017C713   \n",
       "27435  002b63a7e2247de6d62bc62f253474edc7dd044c  SOYGHOJ12A6701FFBA   \n",
       "27418  002b63a7e2247de6d62bc62f253474edc7dd044c  SOXBCZH12A67ADAD77   \n",
       "27427  002b63a7e2247de6d62bc62f253474edc7dd044c  SOXNZOW12AB017F756   \n",
       "26697  003a5e3285141b1a54edbc51fbfa1cc922023aae  SOXAHKA12AF72A5A65   \n",
       "26696  003a5e3285141b1a54edbc51fbfa1cc922023aae  SOWSPUS12AC468BEE3   \n",
       "26698  003a5e3285141b1a54edbc51fbfa1cc922023aae  SOXCEYU12A6D4F3E70   \n",
       "26699  003a5e3285141b1a54edbc51fbfa1cc922023aae  SOXFPND12AB017C9D1   \n",
       "26700  003a5e3285141b1a54edbc51fbfa1cc922023aae  SOXGXKY12A8C13A405   \n",
       "26701  003a5e3285141b1a54edbc51fbfa1cc922023aae  SOXLWPN12A8C143667   \n",
       "26702  003a5e3285141b1a54edbc51fbfa1cc922023aae  SOYFQVR12AB018ACA5   \n",
       "26703  003a5e3285141b1a54edbc51fbfa1cc922023aae  SOYGKNI12AB0187E6E   \n",
       "26704  003a5e3285141b1a54edbc51fbfa1cc922023aae  SOYYFLV12A58A7A88F   \n",
       "26705  003a5e3285141b1a54edbc51fbfa1cc922023aae  SOZGDUH12AF72A6DB2   \n",
       "26695  003a5e3285141b1a54edbc51fbfa1cc922023aae  SOWPRYI12A58A7B51A   \n",
       "26694  003a5e3285141b1a54edbc51fbfa1cc922023aae  SOWKYIJ12AB017B0AA   \n",
       "26681  003a5e3285141b1a54edbc51fbfa1cc922023aae  SOTEPSZ12AB018C99D   \n",
       "26691  003a5e3285141b1a54edbc51fbfa1cc922023aae  SOVTLQW12AB0186641   \n",
       "26664  003a5e3285141b1a54edbc51fbfa1cc922023aae  SOBOUPA12A6D4F81F1   \n",
       "26665  003a5e3285141b1a54edbc51fbfa1cc922023aae  SOFRQTD12A81C233C0   \n",
       "26693  003a5e3285141b1a54edbc51fbfa1cc922023aae  SOWGCMN12A8C136E44   \n",
       "26667  003a5e3285141b1a54edbc51fbfa1cc922023aae  SOGSAYQ12AB018BA14   \n",
       "26668  003a5e3285141b1a54edbc51fbfa1cc922023aae  SOISNSU12AC468C0D8   \n",
       "26669  003a5e3285141b1a54edbc51fbfa1cc922023aae  SOKOXWU12AF72AD1BC   \n",
       "26670  003a5e3285141b1a54edbc51fbfa1cc922023aae  SOLAUOW12A8C13A400   \n",
       "26671  003a5e3285141b1a54edbc51fbfa1cc922023aae  SOLRPJX12A58A79808   \n",
       "26672  003a5e3285141b1a54edbc51fbfa1cc922023aae  SOMGIYR12AB0187973   \n",
       "\n",
       "       play_count  Score  Userid  Songid  \n",
       "18856          16      6       0     300  \n",
       "18860          11      6       0     745  \n",
       "18859           2      2       0     635  \n",
       "18858           6      5       0     377  \n",
       "18857          17      6       0     342  \n",
       "27363           2      2       1     307  \n",
       "27362           9      5       1     306  \n",
       "27361          13      6       1     298  \n",
       "27360           3      3       1     297  \n",
       "27359           3      3       1     292  \n",
       "27358           8      5       1     288  \n",
       "27357           3      3       1     281  \n",
       "27356           1      1       1     273  \n",
       "27355           3      3       1     270  \n",
       "27354           2      2       1     269  \n",
       "27364          15      6       1     309  \n",
       "27445          12      6       1     791  \n",
       "27352           4      4       1     254  \n",
       "27351           2      2       1     241  \n",
       "27350           3      3       1     225  \n",
       "27349           3      3       1     222  \n",
       "27348           3      3       1     215  \n",
       "27347           3      3       1     214  \n",
       "27346           1      1       1     212  \n",
       "27345           2      2       1     210  \n",
       "27344           2      2       1     209  \n",
       "27343          13      6       1     206  \n",
       "27342           1      1       1     200  \n",
       "27341           2      2       1     192  \n",
       "27340           4      4       1     191  \n",
       "...           ...    ...     ...     ...  \n",
       "27431           1      1       1     674  \n",
       "27432           5      4       1     685  \n",
       "27433           3      3       1     692  \n",
       "27434           2      2       1     694  \n",
       "27435           1      1       1     700  \n",
       "27418           1      1       1     606  \n",
       "27427           1      1       1     658  \n",
       "26697          58      8       2     604  \n",
       "26696          51      8       2     589  \n",
       "26698           5      4       2     611  \n",
       "26699          36      8       2     626  \n",
       "26700          14      6       2     632  \n",
       "26701           6      5       2     653  \n",
       "26702          10      6       2     699  \n",
       "26703           7      5       2     702  \n",
       "26704           2      2       2     740  \n",
       "26705           7      5       2     765  \n",
       "26695           6      5       2     577  \n",
       "26694           7      5       2     561  \n",
       "26681           5      4       2     358  \n",
       "26691          54      8       2     510  \n",
       "26664           6      5       2       3  \n",
       "26665           9      5       2      23  \n",
       "26693          21      7       2     543  \n",
       "26667           8      5       2      28  \n",
       "26668           8      5       2      52  \n",
       "26669           8      5       2      71  \n",
       "26670           8      5       2      83  \n",
       "26671           2      2       2      98  \n",
       "26672          52      8       2     113  \n",
       "\n",
       "[200 rows x 6 columns]"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "User_Song_Data.head(200)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 37519 entries, 18856 to 6486\n",
      "Data columns (total 6 columns):\n",
      "user          37519 non-null object\n",
      "song          37519 non-null object\n",
      "play_count    37519 non-null int64\n",
      "Score         37519 non-null int64\n",
      "Userid        37519 non-null int64\n",
      "Songid        37519 non-null int64\n",
      "dtypes: int64(4), object(2)\n",
      "memory usage: 2.0+ MB\n"
     ]
    }
   ],
   "source": [
    "User_Song_Data.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "User_Song_Data=User_Song_Data.drop(['user','song','play_count'], axis = 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 60%做训练，40%做测试\n",
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "UserSong_train,UserSong_test = train_test_split(User_Song_Data, random_state=0, test_size=0.6)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "#UserSong_train = UserSong_train.values\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Score</th>\n",
       "      <th>Userid</th>\n",
       "      <th>Songid</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>6945</th>\n",
       "      <td>1</td>\n",
       "      <td>560</td>\n",
       "      <td>42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35750</th>\n",
       "      <td>3</td>\n",
       "      <td>135</td>\n",
       "      <td>374</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21315</th>\n",
       "      <td>5</td>\n",
       "      <td>681</td>\n",
       "      <td>206</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4294</th>\n",
       "      <td>1</td>\n",
       "      <td>721</td>\n",
       "      <td>314</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9177</th>\n",
       "      <td>3</td>\n",
       "      <td>703</td>\n",
       "      <td>790</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       Score  Userid  Songid\n",
       "6945       1     560      42\n",
       "35750      3     135     374\n",
       "21315      5     681     206\n",
       "4294       1     721     314\n",
       "9177       3     703     790"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "UserSong_train.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Score</th>\n",
       "      <th>Userid</th>\n",
       "      <th>Songid</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>7096</th>\n",
       "      <td>1</td>\n",
       "      <td>544</td>\n",
       "      <td>598</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6444</th>\n",
       "      <td>3</td>\n",
       "      <td>714</td>\n",
       "      <td>532</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21453</th>\n",
       "      <td>1</td>\n",
       "      <td>318</td>\n",
       "      <td>675</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3677</th>\n",
       "      <td>2</td>\n",
       "      <td>110</td>\n",
       "      <td>108</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2322</th>\n",
       "      <td>8</td>\n",
       "      <td>31</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       Score  Userid  Songid\n",
       "7096       1     544     598\n",
       "6444       3     714     532\n",
       "21453      1     318     675\n",
       "3677       2     110     108\n",
       "2322       8      31       0"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "UserSong_test.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_data=UserSong_test.values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "train_data = UserSong_train.values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[  1, 560,  42],\n",
       "       [  3, 135, 374],\n",
       "       [  5, 681, 206],\n",
       "       ...,\n",
       "       [  6, 628, 537],\n",
       "       [  5, 453, 232],\n",
       "       [  6,  47, 321]])"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "#基于物品协同\n",
    "from RS_Item_CF_Song import Item_based_CF_Song\n",
    "\n",
    "song_Item_based_CF = Item_based_CF_Song(train_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the test data size is  (22512, 3)\n",
      "xxx\n",
      "accuray is  0.8187177889743619\n",
      "recall is  0.7786264441591788\n"
     ]
    }
   ],
   "source": [
    "rate_pre_Item = song_Item_based_CF.test(test_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "#基于用户协同\n",
    "from RS_User_CF_Song import User_based_CF_Song\n",
    "\n",
    "song_User_based_CF = User_based_CF_Song(train_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the test data size is  (22512, 3)\n",
      "accuray is  0.8273633284282783\n",
      "recall is  0.7956354300385116\n"
     ]
    }
   ],
   "source": [
    "rate_pre_User= song_User_based_CF.test(test_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "#基于SVD协同\n",
    "from RS_SVD_CF_Song import SVD_CF_Song\n",
    "\n",
    "song_SVD_CF = SVD_CF_Song(train_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "accuray is  0.8090984138937816\n",
      "recall is  0.7683568677792042\n"
     ]
    }
   ],
   "source": [
    "rate_pre_SVD= song_SVD_CF.test(test_data)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "从数据来看，基于用户协同的预测效果最好，但是运行速度最慢"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.7rc1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
